package com.fs.base.exception;

import lombok.extern.log4j.Log4j;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fs.base.exception.enums.ExcEnum;
import com.fs.base.vo.JsonResponse;


/**
 * @author TiddlerCJ
 * @desc 短信异常处理
 */
@Log4j
@ControllerAdvice
public class SMExceptionHandle {
	
	@ExceptionHandler
	@ResponseBody
	public JsonResponse handle(Exception e){
		log.error(e.getMessage(),e);
		if(e instanceof SMException){
			SMException smE = (SMException) e;
			return JsonResponse.error(smE.getCode(), smE.getMessage());
		}else{
			return JsonResponse.error(ExcEnum.EXC_1);
		}
	}
}
